'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	let apiUrl='https://v2.alapi.cn/api/tophub'
	const {data} = await uniCloud.httpclient.request(apiUrl, {
	    method: 'GET',
	    data: {
	      id: "74KvxwokxM",
	      token:"K8NVh0xvERNNSX1l"
	    },
	    contentType: 'json', 
	    dataType: 'json' 
	  })   
	  if(data.code===200){
		  let res = await db.collection('bilibili').add({
		    list: data.data.list,
		    last_update: data.data.last_update,
			date:+new Date()
		  })
		  console.log(res);
		  return res
	  }
};
